package com.elephant.bean;

import jdk.nashorn.internal.runtime.JSONFunctions;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.AbstractRefreshableConfigApplicationContext;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.env.PropertySource;

import java.io.IOException;

/**
 * @author 林
 * @create 2025-05-13 11:08
 */
public class MyClassPathXmlApplicationContext extends ClassPathXmlApplicationContext {

	public MyClassPathXmlApplicationContext(String ... configLocations) {
		super(configLocations);
	}

	//之定义启动
	@Override
	//这个会在refresh的prepareRefresh()方法调用
	public void initPropertySources() {
		System.out.println("做一个扩展");
		getEnvironment().setRequiredProperties("username");
		for (PropertySource<?> propertySource : getEnvironment().getPropertySources()) {
			System.out.println(propertySource.toString());
		}

	}
}
